<template>
	
		<uv-code
			ref="uCode"
			startText="Envoyer"
			@change="codeChange"
			seconds="60"
			changeText="Envoyer Xs"
		></uv-code>
		<uv-button
			@click="getCode"
			:text="tips"
			class="btn-coffee"
			type="coffee"
			size="mini"
		></uv-button>
</template>

<script>
export default{
	props:{
		type:{
			type:[String,Number],
			default:0,
		},
		imgVerify:{
			type:Boolean,
			default:false,
		},
		imgVerifyContent:{
			type:String,
			default:'',
		},
		imgCompareContent:{
			type:String,
			default:''
		},
		phone:{
			type:[String,Number],
			default:''
		}
	},
	data(){
		return {
			tips: '',
			value: '内容'
		}
	},
	mounted() {
	},
	methods:{
		codeChange(text) {
			this.tips = text;
		},
		getCode() {
			
			if (this.$refs.uCode.canGetCode) {
				if(this.imgVerify){
					if(!this.imgVerifyContent){
						uni.$uv.toast("Please entry captcha")
						return false;
					}
					// if(this.imgVerifyContent != this.imgCompareContent){
					// 	uni.$uv.toast("图形验证码不匹配")
					// 	return false;
					// }
				}
				
				// if(!this.phone || (this.phone+'' ).length!==11){
				if(!this.phone ){
					uni.$uv.toast("Please entry phone")
					return false;
				}
				this.submitLoading = true;
				this.$network('/ddzsecurityddzaz/ddzjkgetSmsCode', {
					scenes: 'logOff',
					country: '260',
					mobile: this.phone,
					captcha: this.imgVerifyContent,
					deviceId: this.vuex_deviceId,
					smsType: 1
				}).then((res)=>{
					this.submitLoading = false;
					console.log(res)
					this.$refs.uCode.start();
				}).catch(err=>{
					this.submitLoading = false;
				})
			} else {
				// this.$uv.toast('倒计时结束后再发送');
			}
		},
	}
}
</script>

<style lang="scss" scoped>
	.codeBtn {
		height: 80rpx;
		border-radius: 0;
		background-color: transparent;
		&::after {
			display: none;
		}
	}
	.btn-coffee{
		padding: 10rpx 50rpx;
		border-radius: 10rpx;
	}
</style>
